/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.core.api.config;

import java.util.Collection;

/**
 * Provides read-only access to configuration properties typically defined within an object that implements the
 * {@link IConfigurable}. This includes the <code>IServicePlugin</code> plugins supported by the
 * Proteus Platform Services.
 *
 * @author Tacoma Four
 */
public interface IConfiguration
{
    /**
     * Locates the defined configuration property for the given key.
     *
     * @param key Configuration property key to lookup
     * @return Read-only copy of a configuration property, or null if no configuration property has been set
     *         under that key
     * @throws NoSuchConfigurationException when no prototype matching the given key can be found
     */
    IConfigProperty getConfigProperty(String key) throws NoSuchConfigurationException;

    /**
     * Locates the defined configuration property for the given key, and if no explicit property value has been
     * assigned, automatically return the default value from the corresponding property prototype.
     *
     * @param key Configuration property key to lookup
     * @return Read-only copy of a configuration property assigned value or the prototypes default value if no
     *         configuration property has been explicitly set for the given key
     * @throws NoSuchConfigurationException when no prototype matching the given key can be found
     */
    Object getConfigPropertyOrDefault(String key) throws NoSuchConfigurationException;

    /**
     * Collection of all defined configuration properties. These are values actually set by a caller, and may not
     * represent the complete list of configuration property prototypes supported by the configurable object.
     *
     * @return Unmodifiable collection of defined configuration properties
     */
    Collection<IConfigProperty> configuredProperties();

    /**
     * Provides a detailed list of configuration property prototypes that will be dynamically acknowledge and responded
     * to by the object.
     *
     * @return Non-null list of configuration property prototypes describing what properties are supported
     */
    Collection<IConfigPropertyPrototype> configurableProperties();
}
